<?php

class Cate extends Zend_Db_Table{
  protected $_name = 'cate';
  protected $_primary = 'id';

  public function getCates(){
      return $this->fetchAll();

  }

  public function getCateName($cateId){
      $caterow = $this->getCateById($cateId);
      return $caterow['name'];
  }

  public function getCateById($cateId){
      $db = $this->getAdapter();
      $where = $db->quoteInto('id = ?', $cateId);
      $res = $this->fetchRow($where);
      if($res==null){
          $res['name'] = '未知分类';
          $res['id'] = 0;
          $res['order'] = 0;
          $res['artcount'] = 0;
      }
      return $res;
  }

}
